#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define FILE_NAME(number) "log.txt"#number
int main()
{
    printf("stdin->fd:%d\n",stdin->_fileno);
    printf("stdout->fd:%d\n",stdout->_fileno);
    printf("stderr->fd:%d\n",stderr->_fileno);
    int fd0 = open(FILE_NAME(1),O_WRONLY | O_CREAT | O_APPEND,0666);
    int fd1 = open(FILE_NAME(2),O_WRONLY | O_CREAT | O_APPEND,0666);
    int fd2 = open(FILE_NAME(3),O_WRONLY | O_CREAT | O_APPEND,0666);
    int fd3 = open(FILE_NAME(4),O_WRONLY | O_CREAT | O_APPEND,0666);
    int fd4 = open(FILE_NAME(5),O_WRONLY | O_CREAT | O_APPEND,0666);
   
    printf("fd0:%d\n",fd0);
    printf("fd1:%d\n",fd1);
    printf("fd2:%d\n",fd2);
    printf("fd3:%d\n",fd3);
    printf("fd4:%d\n",fd4);



    close(fd0);
    close(fd1);
    close(fd2);
    close(fd3);
    close(fd4);















    //umask(0);
    //int fd = open(FILE_NAME,O_WRONLY | O_CREAT | O_TRUNC,0666);
    //if(fd == -1) perror("open:");
    //char buff[64]={0};
    //int cnt = 5;
    //while(cnt)
    //{
    //    //sprintf(buff,"%s:%d\n","hello Osfile",cnt--);
    //    sprintf(buff,"%s:%d\n","aaaa",cnt--);
    //    write(fd,buff,strlen(buff));
    //}
    //close(fd);

    return 0;
}
